﻿<%@ Page Language="C#" %>


<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        
        // Create a JSON data table using the following methods
        string jsonDataString = "";
        
        // Static data
        // Using this dataset, the HashCode signature is -882227471
        jsonDataString = "{cols: [{id: 'STYLE', label: 'Programming Style', type: 'string'}, {id: 'FUN', label: 'Fun', type: 'number'}, {id: 'WORK', label: 'Work', type: 'number'}], rows: [{c: [{v: 'Hand Coding'}, {v: 30}, {v: 200}]}, {c: [{v: 'Using the .NET Library'}, {v: 300}, {v: 10}]}, {c: [{v: 'Skipping Visualization'}, {v: -50}, {v: 0}]}]}";
        
       
        
        // Using a 3rd party component conversion of a System.Data.DataTable        
        // In this example the bortosky-google-visualization ( http://code.google.com/p/bortosky-google-visualization/wiki/ReadMe)
        // is used to generate a JSON formatted string from a .NET System.Data.DataTable
        /*
        System.Data.DataTable dt = new System.Data.DataTable();
        dt.Columns.Add("STYLE", typeof(System.String)).Caption = "Programming Style";
        dt.Columns.Add("FUN", typeof(System.Int32)).Caption = "Fun";
        dt.Columns.Add("WORK", typeof(System.Int32)).Caption = "Work";
        dt.Rows.Add(new object[] { "Hand Coding", 30, 200 });
        dt.Rows.Add(new object[] { "Using the .NET Library", 300, 10 });
        dt.Rows.Add(new object[] { "Skipping Visualization", -50, 0 });

        Bortosky.Google.Visualization.GoogleDataTable gdt = new Bortosky.Google.Visualization.GoogleDataTable(dt);
        using (System.IO.MemoryStream mem = new System.IO.MemoryStream())
        {
            gdt.WriteJson(mem);
            mem.Position = 0;
            System.IO.StreamReader sr = new System.IO.StreamReader(mem);
            jsonDataString= sr.ReadToEnd();
            sr.Close();
        }
         */
        

        //Pick up the URL request parameters.
        Intergr8.GoogleVisualization.RequestHandler reqHandler = Intergr8.GoogleVisualization.RequestHandler.CreateRequestHandler(Request.QueryString);

        
        // Wrap up the data to return
        Intergr8.GoogleVisualization.IResponseData data = Intergr8.GoogleVisualization.ResponseData.GenerateResponseData(jsonDataString);
        
        // Generate a Response
        Intergr8.GoogleVisualization.IResponseMessage responseMessage = Intergr8.GoogleVisualization.ResponseMessage.CreateResponse(reqHandler, data);
        
        // Correctly set the content and MIME type
        Response.ContentType = "text/plain";
        Response.Charset = "UTF-8";

        // Write the Response
        Response.Write(responseMessage.Output());
         

    }

</script>


